import Vue from 'vue'
import Router from 'vue-router'
import SignPage from "../pages/SignPage";
import HomePage from "../pages/HomePage";
import LoginBlock from "../components/signComponents/LoginBlock";
import RegistBlock from "../components/signComponents/RegistBlock";
import First from "../components/homeComponents/First";
import Library from "../components/homeComponents/Library";
import Cart from "../components/homeComponents/Cart";
import Recommend from "../components/homeComponents/Recommend";
import Hot from "../components/homeComponents/Hot";
import RightManagement from "../components/homeComponents/RightManagement";
import RoleManagement from "../components/homeComponents/RoleManagement";
import UserManagement from "../components/homeComponents/UserManagement";
import bookDetail from "../components/detailComponents/bookDetail";
import UserDetail from "../components/homeComponents/UserDetail";
import MyStore from "../components/homeComponents/MyStore";
import SearchBooks from "../components/homeComponents/SearchBooks";
import orderDetail from "../components/detailComponents/orderDetail";
import MyInformation from "../components/homeComponents/MyInformation";
import BookTypeDiagram from "../components/homeComponents/EchartsDiagrams/BookTypeDiagram";
import UserAgeDiagram from "../components/homeComponents/EchartsDiagrams/UserAgeDiagram";
import CategorySearch from "../components/homeComponents/CategorySearch";


Vue.use(Router)

//获取原型对象上的push函数
const originalPush = Router.prototype.push
//修改原型对象中的push方法
Router.prototype.push = function push(location) {
    return originalPush.call(this, location).catch(err => err)
}

export default new Router({
    routes:[
        {path:'/',redirect:'/sign'},
        {path:'/sign',
            component: SignPage,
            children:[
                {path:'/sign/login',component:LoginBlock},
                {path:'/sign/register',component:RegistBlock}
            ],
            redirect:'/sign/login'
        },
        {
            path:'/home',
            component: HomePage,
            children:[
                {path: '/home/first',component: First},
                {path: '/home/library',component: Library},
                {path: '/home/cart',component: Cart},
                {path: '/home/recommend',component: Recommend},
                {path: '/home/hot',component: Hot},
                {path: '/home/bookdetail',component: bookDetail},
                {path: '/home/user',component: UserDetail},
                {path: '/home/search',component: SearchBooks},
                {path: '/home/CategorySearch',component: CategorySearch},

                {path: '/home/rightManagement',component: RightManagement},
                {path: '/home/roleManagement',component: RoleManagement},
                {path: '/home/userManagement',component: UserManagement},

                {path: '/home/myStore',component: MyStore},
                {path: '/home/orderDetail',component: orderDetail},
                {path: '/home/bookTypeMap',component: BookTypeDiagram},
                {path: '/home/userAgeMap',component: UserAgeDiagram},

                {path: '/home/myInformation',component: MyInformation}

            ],
            redirect:'/home/first'
        }
    ],
    mode:"hash"
})
